#ifndef QMACHINEVALUE_H
#define QMACHINEVALUE_H

#include "machine_global.h"

#include <QObject>
#include <QVariant>
#include <QMap>
#include <QStringList>

enum enValuePropertyIndex
{
    EPI_CODE,
    EPI_NAME,
    EPI_ADDRESS,
    EPI_LENGTH,
    EPI_SCALE,
    EPI_DEFAULT,
    EPI_MIN_VALUE,
    EPI_MAX_VALUE,
    EPI_UNIT,
    EPI_WRITE_TYPE,
    EPI_SHOW_TYPE,
    EPI_INFORAMTION,
    EPI_START_READ,
    EPI_BOTTOM
};

class MACHINELIB_EXPORT QMachineValue : public QObject
{
    Q_OBJECT
public:
    explicit QMachineValue(QObject *parent = 0);
    QVariant        get_value_property(enValuePropertyIndex index);
    void            set_value_property(enValuePropertyIndex index,const QVariant& value);

    int             get_base_value();
    double          get_true_value();
    void            set_base_value(int value);
    void            set_true_value(double value);

    QString         get_true_value_string();
    QString         get_true_value_string(double value);
    QStringList     get_combo_list();

    int             get_true_value_from_string(const QString &value);
signals:
    void            value_changed();
public slots:
protected:
    int         m_value;

    QStringList         m_combo_list;
    QMap<int,QString>   m_value_combo_text;
};

#endif // QMACHINEVALUE_H
